<template>
  <view>
    <one-to-one-card-of-user-account
        :person="person"
    ></one-to-one-card-of-user-account>
  </view>
</template>

<script>

import OneToOneCardOfUserAccount from "./components/one-to-one-card-of-user-account.vue";

export default {
  components: {OneToOneCardOfUserAccount},
  props: {
    dialog: {
      type: Object,
      default: {
        oneToOneIdentifier: "",
      }
    }
  },
  data() {
    return {
      oneToOnePersons: [],
      person: {
        type: "",
        value: ""
      }
    }
  },
  watch: {
    dialog: {
      handler(val) {
        this.oneToOnePersons = [];
        let oneToOneIdentifierSplit = val.oneToOneIdentifier.split("&");
        for (let i = 0; i < oneToOneIdentifierSplit.length; i++) {
          const element = oneToOneIdentifierSplit[i];
          let strings = element.split(":");
          let type = strings[0];
          let value = strings[1];
          this.oneToOnePersons.push({
            type: type,
            value: value
          });
        }
        // 获取用户信息
        let self = this.$kt.userAccount.getSelf();
        for (let i = 0; i < this.oneToOnePersons.length; i++) {
          const element = this.oneToOnePersons[i];
          // 不是自己则赋值给person
          if (element.value+"" !== self.id+"") {
            this.person.type = element.type;
            this.person.value = element.value;
          }
        }

      },
      immediate: true,
      deep: true
    }
  },
  mounted() {

  },
  methods: {}
}
</script>

<style lang="scss" scoped>
</style>
